/**
 * Created by zhulizhe on 2017/8/30.
 */
import Store from 'react-native-store';

const DB = {
    keyword: Store.model('search_word_history'),
}

class HistorySearchStore {


    // 追加关键词
    addKeyword(words = []) {
        if (words && words.length > 0) {
            words.map((word) => {
                if(word&&word.length!=0){
                    DB.keyword.add({history: word});
                }
            })
        }
    }

    // 获取历史搜索
    loadHistory() {
        return DB.keyword.find();
    }

    // 清空历史搜索
    clear() {
        DB.keyword.destroy();
    }
}

export const historySearchStore = new HistorySearchStore();
